package edu.gdkm.demo;

public class Demo33 {
    public static void main(String[] args) {
        //字符串的创建
        String s1 = "abc";   // int a = 100;
        String s2 = new String("abc");
        char cs[]={'a','b','c'};
        String s3 = new String(cs);
        String s4 =new String(s1);
        String s5 = s1;
        System.out.println("s1:"+s1);
        System.out.println("s2:"+s2);
        System.out.println("s3:"+s3);
        System.out.println("s4:"+s4);
        System.out.println("s5:"+s5);
        //基本数据类型：==判断两侧运算数的值是否相同
        //引用数据类型：==判断两侧对象是否内存地址是否相同
        System.out.println("s1==s2:"+(s1==s2));
        System.out.println("s1==s3:"+(s1==s3));
        System.out.println("s1==s4:"+(s1==s4));
        System.out.println("s1==s5:"+(s1==s5));
        System.out.println("s2==s3:"+(s2==s3));
        System.out.println("s2==s4:"+(s2==s4));
        System.out.println("s2==s5:"+(s2==s5));
        System.out.println("s3==s4:"+(s3==s4));
        System.out.println("s3==s5:"+(s3==s5));
        System.out.println("s4==s5:"+(s4==s5));
        System.out.println("----------------------------------------");
        System.out.println(s1.equals(s2));
        System.out.println(s2.equals(s3));
        System.out.println(s3.equals(s4));
        System.out.println(s4.equals(s5));
        System.out.println("----------------------------------------");
        String name1="张三";
        String name2="abc";
        String name3="abc";
        System.out.println(name1.equals(name2));
        System.out.println(name2.compareTo(name3));

    }
}
